<template>
  <div class="home">
    <div class="contentInput">
      <input type="text" v-model="value" placeholder="请输入内容">
      <button @click="typeIn">输入</button>
    </div>
    <p>{{ $store.state.info }}</p>
  </div>
</template>

<script>
export default {
  data () {
    return {
      value: ''
    }
  },
  mounted () {
    if (sessionStorage.getItem('info' != null)) {
      this.$store.commit('setInfo', sessionStorage.getItem('info'))
    }
  },
  methods: {
    typeIn () {
      sessionStorage.setItem('info', this.value)
      this.$store.commit('setInfo', this.value)
      this.value = ''
    }
  }
}
</script>
